package com.irs.irsforum.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.irs.irsforum.entity.IndexPage;
import com.irs.irsforum.entity.IndexPost;
import com.irs.irsforum.entity.Post;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author yihuili
 * @since 2020-01-18
 */
@Mapper
public interface PostMapper extends BaseMapper<Post> {

    List<IndexPost> showPostByPage(IndexPage indexPage);

    Integer getTotalNum();

    Post showPost(@Param("postId") Long postId, @Param("userId") Long userId);

    Integer writePost(@Param("post") Post post);

    Integer hasPost(@Param("postId") Long postId);

    List<IndexPost> getPostByUserId(@Param("userId") Long userId);

    List<IndexPost> getFavoriteByUserId(@Param("userId") Long userId);

    Integer updateCommentNum(@Param("postId") Long postId, @Param("number") Long number);

    Integer updateFavoriteNum(@Param("postId") Long postId, @Param("number") Long number);

    Integer updateIsExist(@Param("number") Long number, @Param("postId") Long postId);

    Integer isExistPost(@Param("postId") Long postId, @Param("userId") Long userId);

    Post getProSubById(@Param("postId") Long postId);

    List<IndexPost> getIndexPostByList(IndexPage indexPage);
}
